import {
    Entity,
    PrimaryKey,
    Property,
    ManyToOne,
    Reference,
} from "@mikro-orm/core";
import { BaseEntity } from "./Base";
import { User } from "./User";
import { App } from "./App";

@Entity()
export class AppUser extends BaseEntity {
    @ManyToOne({ entity: () => App, nullable: true })
    app!: Reference<App>; // response to filed 'app_id'

    @ManyToOne({ entity: () => User, nullable: true })
    user!: Reference<User>; // response to filed 'user_id'

    @Property({ type: "numeric", default: 0, columnType: "int" })
    isDelete: number = 0;

    constructor({
        app,
        isDelete,
        user,
    }: {
        app: Reference<App>;
        user: Reference<User>;
        isDelete: number;
    }) {
        super();
        this.isDelete = isDelete;
        this.app = app;
        this.user = user;
    }
}
